Socket
Socket
Sign inDemoInstall

@swagger-api/apidom-core

Package Overview
Dependencies
Maintainers
1
Versions
52
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@swagger-api/apidom-core

Tools for manipulating ApiDOM structures.


Version published
Weekly downloads
462K
increased by2.33%
Maintainers
1
Weekly downloads
 
Created

What is @swagger-api/apidom-core?

@swagger-api/apidom-core is a core library for working with API definitions in various formats such as OpenAPI, AsyncAPI, and JSON Schema. It provides tools for parsing, transforming, and serializing API documents, making it easier to work with these specifications programmatically.

What are @swagger-api/apidom-core's main functionalities?

Parsing API Documents

This feature allows you to parse API documents written in OpenAPI, AsyncAPI, or JSON Schema formats. The code sample demonstrates parsing an OpenAPI document and logging the parsed result.

const { parse } = require('@swagger-api/apidom-core');

const openApiDocument = `
openapi: 3.0.0
info:
  title: Sample API
  version: 0.1.0
paths:
  /example:
    get:
      summary: Example endpoint
      responses:
        '200':
          description: Successful response
`;

parse(openApiDocument).then((parsedDoc) => {
  console.log(parsedDoc);
}).catch((error) => {
  console.error('Error parsing document:', error);
});

Transforming API Documents

This feature allows you to apply transformations to API documents. The code sample demonstrates transforming an OpenAPI document by changing its title.

const { transform } = require('@swagger-api/apidom-core');

const openApiDocument = `
openapi: 3.0.0
info:
  title: Sample API
  version: 0.1.0
paths:
  /example:
    get:
      summary: Example endpoint
      responses:
        '200':
          description: Successful response
`;

const transformation = (doc) => {
  doc.info.title = 'Transformed API';
  return doc;
};

transform(openApiDocument, transformation).then((transformedDoc) => {
  console.log(transformedDoc);
}).catch((error) => {
  console.error('Error transforming document:', error);
});

Serializing API Documents

This feature allows you to serialize parsed API documents back into their respective formats. The code sample demonstrates serializing a parsed OpenAPI document.

const { serialize } = require('@swagger-api/apidom-core');

const parsedDoc = {
  openapi: '3.0.0',
  info: {
    title: 'Sample API',
    version: '0.1.0'
  },
  paths: {
    '/example': {
      get: {
        summary: 'Example endpoint',
        responses: {
          '200': {
            description: 'Successful response'
          }
        }
      }
    }
  }
};

serialize(parsedDoc).then((serializedDoc) => {
  console.log(serializedDoc);
}).catch((error) => {
  console.error('Error serializing document:', error);
});

Other packages similar to @swagger-api/apidom-core

FAQs

Package last updated on 03 Nov 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc